<?php 
session_start();
require_once("include/authen.php");
require_once("include/ui.php");
if ($_SESSION["permission"][$top_sale_report]["View"]=="0"){
	echo "<script>alert('".$no_permit."');</script>";
	echo "<meta http-equiv = refresh ; content = '0 ; url = mainscreen.php'>";
	exit();
}
echo headerPage("Top Sale Report");
?>
<script>
$(function() {
	$('#dtSaleFrom,#dtSaleTo').datepicker({ dateFormat: 'dd/mm/yy',
		showOn: "button",
				changeMonth: true,
		changeYear: true,
		yearRange:'c-10:c+1',			
		buttonImage: "images/Calendar.png",
		buttonImageOnly: true });
		
	$.get('a_user.php',{"c":"b"},function(data){
		$.each(eval('('+data+')'), function(index, text) {
			$("#cboBranch").append(
					$('<option></option>').val(text	).html(index)
			 );
		});
		if ( $("#isHO").val()=='0' ) 
			$("#cboBranch").val($("#bid").val()).attr('disabled','disabled');
	});
	if ( $("#isHO").val()=='1' ) 
		$("#cboBranch").append($('<option></option>').val(0).html('All'));
	
	$("#btnPrint").button({
				icons:{
				 primary: "ui-icon-print"
				}
			});	
	$("#cboBranch").attr('disabled','disabled');
	
	$("input:radio[name:reportType]").click(function(){
		var i=$("input:radio[name:reportType]:checked").val();
		if (i != "0")
			if ($("#isHO").val()==1){
				$("#cboBranch").removeAttr('disabled');
			}else {
				$("#cboBranch").val($("#bid").val()).attr('disabled','disabled');
			}
		else 	
			$("#cboBranch").attr('disabled','disabled');
			 
	});
	
	$("#btnPrint").click(function(){
		
		if ($("#dtSaleFrom").val().length < 1) {
			alert("Please input SaleDate");
			return false;
		}else if ($("#dtSaleTo").val().length < 1) {
			alert("Please input SaleDate");
			return false;
		}else  {
			$("#dFrom").val( $("#dtSaleFrom").val() );
			$("#dTo").val( $("#dtSaleTo").val() );
			$("#branch").val( $("#cboBranch").val() );
			$("#type").val( $("input:radio[name:reportType]:checked").val() );
			$("#branchName").val( $("#cboBranch option:selected").text());
			
			//alert($("#dFrom").val());
			//$("#Act").submit();		
			return true;
		}
	});
});
</script>

<FORM name="Act" id="Act" action="topsale.php" method="post" target="_blank"> 
<INPUT type=hidden value="" id="dFrom" name="dFrom"> 
<INPUT type=hidden value="" id="dTo" name="dTo"> 
<INPUT type=hidden value="" id="branch" name="branch"> 
<INPUT type=hidden value="" id="branchName" name="branchName"> 
<INPUT type=hidden value="" id="type" name="type"> 
<INPUT type=hidden value="<?php echo $_SESSION['bid'];?>" id="bid" name="bid"> 
<INPUT type=hidden value="<?php echo $_SESSION['branchtype'];?>" id="isHO" name="isHO"> 
<table width="1024" height="400px" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
     <td width="10" style='border-left:2px solid #facb0c;'>&nbsp;</td>
    <td width="1004" valign="top">
        <div class="content-box" >
            <div Class="toolbar-box">   
                <div class="t">
                    <div class="t">
                        <div class="t"></div>
                    </div>
                 </div>
                 <div class="m">
                    <div class="toolbar">
                        <table class="toolbar">
                        <tr><td></td>
                         </tr>
                        </table>
                    </div>
                      <div class="header" style="background-image: url(images/doc.png);">
						Top Sale Report
                      </div>
                <div class="clr"></div>
                 </div>
                 <div class="b">
                    <div class="b">
                        <div class="b"></div>
                    </div>
                 </div>
            </div>
               <div id="element-box">
                <div class="t">
					<div class="t">
						<div class="t"></div>
					</div>
				</div>
                <div class="m">
				<fieldset  class="ui-widget ui-widget-content">
				<legend>Top Sale Report</legend>	
                    <table width="100%"  id="infotable" style="line-height:36px">
                        <tr>
                            <td width="40%" class="fontSearch" style="padding-left:20;font-weight:normal;">
								<label for="name">&nbsp;&nbsp;Sale Date From : </label>
								<input type='text' id='dtSaleFrom' style='font-size:12px;padding:3px;border:1px solid #ccc' name='dtSaleFrom' stype value=""/>
							</td>
                            <td width="60%" class="fontSearch" style="padding-left:20;font-weight:normal;">
								<label for="name">Sale Date To : </label>
								<input type='text' id='dtSaleTo' name='dtSaleTo' style='font-size:12px;padding:3px;border:1px solid #ccc' value=""/>
							</td>							
						</tr>
						<tr>
							<td width="100%" colspan="2" class="fontSearch" style="padding-left:20;font-weight:normal;">
								<label for="name">&nbsp;&nbsp;Branch : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
								<select id='cboBranch'  style='font-size:12px;padding:2px;'></select>
							</td>
						</tr>
						<tr>
							<td width="100%" colspan="2" class="fontSearch" style="padding-left:20;font-weight:normal;"><label for="name" >&nbsp;&nbsp;Report Type : </label>
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='radio' name='reportType' id='Type_1' value="0" checked/>รายได้รวม
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<input type='radio' name='reportType' id='Type_2' value="1" />สินค้าขายดี
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<input type='radio' name='reportType' id='Type_3' value="2" />Treatment ขายดี
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<input type='radio' name='reportType' id='Type_4' value="3" />Set ขายดี
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<input type='radio' name='reportType' id='Type_5' value="4"  />Course ขายดี
							</td>
						</tr>
						<tr>
							<td width="100%" colspan="2" class="fontSearch" style="padding-right:20px;" align="right">
								<button id="btnPrint" style="font-size:12px">Print</button>
							</td>
						</tr>
                    </table>
				</fieldset>
				<p></P>
                 <div class="clr"></div>
                </div>
                 <div class="b"><div class="b"><div class="b"></div></div></div>
                 <div class="clr"></div>
                </div> <!-- elementbox-->
        </div>
    </td>
    <td width="10"  style='border-right:2px solid #facb0c;' >&nbsp;</td>
  </tr>
</table>
 </FORM>
<?php echo footer();?>